<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增易货订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-order-add">
            <h4 class="form-header h4">易货订单信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主键：</label>
                <div class="col-sm-8">
                    <input name="id" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入用户id A 主动：</label>
                <div class="col-sm-8">
                    <input name="userInid" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出用户id B 被动：</label>
                <div class="col-sm-8">
                    <input name="userOutid" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">订单编号：</label>
                <div class="col-sm-8">
                    <input name="orderNo" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入产品物流单号 A：</label>
                <div class="col-sm-8">
                    <input name="changeIntrackno" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出产品物流单号 B：</label>
                <div class="col-sm-8">
                    <input name="changeOuttrackno" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入物流公司名称A：</label>
                <div class="col-sm-8">
                    <input name="changeIntrackname" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入物流公司编码A：</label>
                <div class="col-sm-8">
                    <input name="changeIntracknamecode" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出保证金状态 B  0未缴纳，1已缴纳 -1已退回：</label>
                <div class="col-sm-8">
                    <select name="changeOutstatus" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入订单保证金A：</label>
                <div class="col-sm-8">
                    <input name="securityInmoney" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出订单保证金B：</label>
                <div class="col-sm-8">
                    <input name="securityOutmoney" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入订单状态 A 0待回复 1待确认 2待发货 3待收货 4已完成 5关闭：</label>
                <div class="col-sm-8">
                    <select name="orderInstatus" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出订单状态 B 0待回复 1待确认 2待发货 3待收货 4已完成 5关闭：</label>
                <div class="col-sm-8">
                    <select name="orderOutstatus" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收货地址 B：</label>
                <div class="col-sm-8">
                    <input name="orderInaddress" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收货地址 B：</label>
                <div class="col-sm-8">
                    <input name="orderOutaddress" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入手机号 A：</label>
                <div class="col-sm-8">
                    <input name="orderInphone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出手机号 B：</label>
                <div class="col-sm-8">
                    <input name="orderOutphone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入收货人 A：</label>
                <div class="col-sm-8">
                    <input name="orderInname" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出收货人 B：</label>
                <div class="col-sm-8">
                    <input name="orderOutname" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换出物流公司编码B：</label>
                <div class="col-sm-8">
                    <input name="changeOuttracknamecode" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">换入保证金状态 A 0未缴纳，1已缴纳 -1已退回：</label>
                <div class="col-sm-8">
                    <select name="changeInstatus" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <h4 class="form-header h4">订单商品表信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "jjyh/order"
        $("#form-order-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-order-add').serialize());
            }
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'id',
                    align: 'center',
                    title: '订单商品表',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].id' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '生成时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'goodsId',
                    align: 'center',
                    title: '商品id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].goodsId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'price',
                    align: 'center',
                    title: '价格',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].price' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'num',
                    align: 'center',
                    title: '数量',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].num' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'type',
                    align: 'center',
                    title: '分类 1换入  2换出',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].type' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userId',
                    align: 'center',
                    title: '商品归属人id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='jjyhOrderGoodsList[%s].userId' value='%s'>", index, value);
                        return html;
                    }
                
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    id: "",
                    createTime: "",
                    goodsId: "",
                    price: "",
                    num: "",
                    type: "",
                    userId: ""
                }
            });
        }
    </script>
</body>
</html>